﻿
@{
    ViewBag.Title = "上传Excel";
}

<h2>上传Excel文件</h2>

<form action="/Home/UpLoadFiles" method="post" enctype="multipart/form-data">
    <input type="file" id="files" name="files" value="" />
    <input type="button" id="btnOK" name="btnOK" value="上传" onclick="onUpLoad()" />
    <input type="button" name="btnDown" value="下载" id="btnDown" onclick="onDown()" />
</form>

<script>

    ///上传
    function onUpLoad() {
        var formData = new FormData();
        formData.append("MyFiles", document.getElementById("files").files[0]);
        $.ajax({
            type: "POST",
            url: "/Home/UpLoadFilesExcel",
            data: formData,
            async: false,
            dataType: "json",
            contentType: false,
            processData: false,
            success: function (data) {
                if (data.status == "true") {
                    alert("上传成功!");
                }
                else {
                    alert("上传失败!");
                }
                $("#files").val("");
                //window.location.reload();
            }
        });
    }


    function onDown() {
        $.post("/Home/DownExcel", "",
            function (data, textStatus, jqXHR) {

            },
            "json"
        );
    }

</script>